package <%= class_name.downcase.gsub('::','.') %>.model
{
	import mx.collections.ArrayCollection;
	import mx.formatters.CurrencyFormatter;
	import mx.formatters.NumberFormatter;
	import mx.formatters.DateFormatter;
		
	import org.genuflex.model.GenuflexModelLocator;

	import <%= class_name.downcase.gsub('::','.') %>.vo.*;
   
	[Bindable]
	public class <%= file_name.camelcase %>ModelLocator extends GenuflexModelLocator {
		
		private static var modelLocator : <%= file_name.camelcase %>ModelLocator;
      
		/* Collections */
		
		
		/* Current Selections */
		
		/* Formatters */	  
		public var currencyFormatter : CurrencyFormatter;
		public var numberFormatter : NumberFormatter;
		public var dateFormatter : DateFormatter;
		public var timeFormatter : DateFormatter;
		
	    public static function getInstance() : <%= file_name.camelcase %>ModelLocator {
	    	if ( modelLocator == null ) {
	      		modelLocator = new <%= file_name.camelcase %>ModelLocator();
	      	}
		
			return modelLocator;
		}
	      
		public function <%= file_name.camelcase %>ModelLocator() {	
			if ( modelLocator != null ) {
				throw new Error( "Only one <%= file_name.camelcase %>ModelLocator instance should be instantiated" );	
			}

	       	currencyFormatter = getCurrencyFormatter();
	       	numberFormatter = getNumberFormatter();	       	
			dateFormatter = getDateFormatter();		
			timeFormatter = getTimeFormatter();	

	    }

	    private function getCurrencyFormatter() : CurrencyFormatter
	    {
	       var formatter:CurrencyFormatter = new CurrencyFormatter();
	       formatter.currencySymbol = "$";
	       formatter.precision = 2;

	       return formatter;
	    }  

	    private function getNumberFormatter() : NumberFormatter
	    {
	       var formatter:NumberFormatter = new NumberFormatter();
	       formatter.precision = 2;	          
	       return formatter;
	    }  	    

	    private function getDateFormatter() : DateFormatter
	    {
	       var formatter:DateFormatter = new DateFormatter();
	       formatter.formatString = "MM/DD/YY";

	       return formatter;
	    }

	    private function getTimeFormatter() : DateFormatter {
	    	var formatter:DateFormatter = new DateFormatter();
	    	formatter.formatString = "L:NN A";
	    	return formatter;
	    }   

	    public function formatDate(datetime : Date) : String {
	    	return this.dateFormatter.format(datetime);
	    }	    	            	
	    public function formatDateTime(datetime : Date) : String {
	    	return this.dateFormatter.format(datetime) + " "  + this.timeFormatter.format(datetime);
	    }	    	            	
	    public function formatNumber(number: Number) : String {
			return this.numberFormatter.format(number);
	    }	   
	}
}
